<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="utf-8">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        {{a}}
    </div>

    <script type="text/javascript">
        /*
        操作b的属性值,需要提前声明b
        */
        var data={a:1};
        var vm = new Vue({
            el:"#app",
            data: data
        });
        vm.$watch('a',function(newVal,oldVal){
            console.log(newVal,oldVal);
        });
        vm.$data.a="test123";
    </script>
</body>

</html>